﻿
(function () {
    appModule.controller('common.views.disputeInformationHandles.fenLiu', [
         '$scope', '$uibModalInstance', 'abp.services.app.disputeInformation', 'disputeInformationId', 'abp.services.app.disputeType', 'disputeInformation', 'abp.services.app.area',
        function ($scope, $uibModalInstance, disputeInformationService, disputeInformationId, disputeTypeService, disputeInformation, areaService) {
            var vm = this;
            vm.saving = false;
            //首先将disputeInformation数据设置为null
            vm.disputeInformation = null;



            //触发保存方法
            vm.save = function () {
                vm.saving = true;
                vm.disputeInformation.processContent = '进行纠纷事件分流';
                disputeInformationService.createOrUpdateDisputeInformationAsync({ disputeInformationEditDto: vm.disputeInformation }).then(function () {
                    abp.notify.info(app.localize('SavedSuccessfully'));
                    $uibModalInstance.close();
                }).finally(function () {
                    vm.saving = false;
                });


            };
            //取消关闭页面
            vm.cancel = function () {
                $uibModalInstance.dismiss();
            };

            //初始化页面
            function init() {

                //绑定镇控件
                areaService.getAreaByLevelAsync({ id: 0 }).then(function (result) {
                    vm.townList = result.data.items;
                });

                disputeInformationService.getDisputeInformationForEditAsync({
                    id: disputeInformationId
                }).then(function (result) {
                    vm.disputeInformation = result.data.disputeInformation;
                });

            }

            //执行初始化方法
            init();
        }
    ]);
})();